package com.maxh.util;


public class ReturnData {

    /**
     * 状态码
     */
    private int code;

    /**
     * 返回数据
     */
    private Object data;


    /**
     * 返回信息
     */
    private String msg;

    public ReturnData() {
    }

    public ReturnData(Object data) {
        this.data = data;
    }

    public ReturnData(int code, Object data) {
        this.code = code;
        this.data = data;
    }

    public ReturnData(int code, Object data, String msg) {

        this.code = code;
        this.data = data;
        this.msg = msg;
    }
    public ReturnData(int code,  String msg) {
        this.code = code;
        this.msg = msg;
    }
    public ReturnData(StatusCode userResponseEnum, String msg){
        this.msg = msg;
        this.code = userResponseEnum.getCode();
    }
    public ReturnData(StatusCode userResponseEnum, Object data, String msg){
        this.data = data;
        this.msg = msg;
        this.code = userResponseEnum.getCode();
    }

    public ReturnData success(){
        this.code = 200;
        this.data = true;
        this.msg = "请求成功";
        return this;
    }

    public ReturnData success(Object data){
        this.code = 200;
        this.data = data;
        this.msg = "请求成功";
        return this;
    }

    public ReturnData error(){
        this.code = 500;
        this.data = false;
        this.msg = "请求失败";
        return this;
    }

    public ReturnData error(Object data,String msg){
        this.code = 500;
        this.data = data;
        this.msg = msg;
        return this;
    }

    /*set get方法*/

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }


    //----------
}
